# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=jupyterlab
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=4.4.2
pkgrel=1
pkgdesc='JupyterLab computational environment (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://jupyterlab.readthedocs.io/'
msys2_repository_url='https://github.com/jupyterlab/jupyterlab/'
msys2_references=(
  'archlinux: jupyterlab'
  'purl: pkg:pypi/jupyterlab'
)
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-async-lru"
         "${MINGW_PACKAGE_PREFIX}-python-ipykernel"
         "${MINGW_PACKAGE_PREFIX}-python-jinja"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter_core"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter-lsp"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter_server"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter_notebook_shim"
         "${MINGW_PACKAGE_PREFIX}-python-jupyterlab-server"
         "${MINGW_PACKAGE_PREFIX}-python-httpx"
         "${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-traitlets"
         "${MINGW_PACKAGE_PREFIX}-python-tornado"
)
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-hatch-jupyter-builder"
             "${MINGW_PACKAGE_PREFIX}-python-installer")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('afa9caf28c0cb966488be18e5e8daba9f018a1c4273a406b7d5006344cbc6d16')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}"${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
